package com.vickcan.vdp.service.impl;

import cn.hutool.core.util.RuntimeUtil;
import cn.hutool.core.util.StrUtil;
import com.vickcan.vdp.config.CfgFactory;
import com.vickcan.vdp.domain.VConfig;
import com.vickcan.vdp.service.IDeployService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

/**
 * @Author: ByteExpress
 * @Date: 2024/8/28 22:29
 * @Version V1.0
 */
@Slf4j
@Service
@RequiredArgsConstructor
public class DeployServiceImpl implements IDeployService {
    private final CfgFactory cfgFactory;

    @Override
    public void compile(String id) {
        VConfig vConfig = cfgFactory.getById(id);
        String cmd = StrUtil.format("mvn clean install -P {}", vConfig.getCompile().getBranch());
        String str = RuntimeUtil.execForStr(cmd);
    }

    @Override
    public void deploy(String id) {

    }
}
